home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / os-probes / 50mounted-tests
Encoding:
Text File  |  2007-01-11  |  971 b   |  46 lines

  1. #!/bin/sh
  2. # Sub-tests that require a mounted partition.
  3. set -e
  4. partition=$1
  5.  
  6. . /usr/share/os-prober/common.sh
  7.  
  8. tmpmnt=/var/lib/os-prober/mount
  9. if [ ! -d $tmpmnt ]; then
  10.     mkdir $tmpmnt
  11. fi
  12.  
  13. for type in $(grep -v nodev /proc/filesystems); do
  14.     # hfsplus filesystems are mountable as hfs. Try hfs last so that we
  15.     # can tell the difference.
  16.     if [ "$type" = hfs ]; then
  17.         delaytypes="${delaytypes:+$delaytypes }$type"
  18.     else
  19.         types="${types:+$types }$type"
  20.     fi
  21. done
  22.  
  23. for type in $types $delaytypes; do
  24.     if mount -o ro -t $type $partition $tmpmnt 2>/dev/null; then
  25.         debug "mounted as $type filesystem"
  26.         for test in /usr/lib/os-probes/mounted/*; do
  27.             debug "running subtest $test"
  28.             if [ -f $test ] && [ -x $test ]; then
  29.                 if $test $partition $tmpmnt $type; then
  30.                     debug "os found by subtest $test"
  31.                     umount $tmpmnt
  32.                     rmdir $tmpmnt || true
  33.                     exit 0
  34.                 fi
  35.             fi
  36.         done
  37.         umount $tmpmnt
  38.         break
  39.     fi
  40. done
  41.  
  42. rmdir $tmpmnt || true
  43.  
  44. # No tests found anything.
  45. exit 1
  46.